package cn.brilliantfuture.commentry.entity;

// Generated 2011-11-3 13:34:34 by Hibernate Tools 3.3.0.GA

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * Role generated by hbm2java
 */
@Entity
@Table(name = "role", catalog = "cabinet")
public class Role implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer roleId;
	private String name;
	private String description;
	private boolean deleted;
	private String roleKey;
	private Set<RolePrivilege> rolePrivileges = new HashSet<RolePrivilege>(0);
	private Set<CommunityRole> communityRoles = new HashSet<CommunityRole>(0);

	public Role() {
	}

	public Role(String name, boolean deleted) {
		this.name = name;
		this.deleted = deleted;
	}

	public Role(String name, String description, boolean deleted,
			String roleKey, Set<RolePrivilege> rolePrivileges,
			Set<CommunityRole> communityRoles) {
		this.name = name;
		this.description = description;
		this.deleted = deleted;
		this.roleKey = roleKey;
		this.rolePrivileges = rolePrivileges;
		this.communityRoles = communityRoles;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "role_id", unique = true, nullable = false)
	public Integer getRoleId() {
		return this.roleId;
	}

	public void setRoleId(Integer roleId) {
		this.roleId = roleId;
	}

	@Column(name = "name", nullable = false, length = 45)
	@NotNull
	@Length(max = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "description", length = 45)
	@Length(max = 45)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "deleted", nullable = false)
	public boolean isDeleted() {
		return this.deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	@Column(name = "role_key", length = 45)
	@Length(max = 45)
	public String getRoleKey() {
		return this.roleKey;
	}

	public void setRoleKey(String roleKey) {
		this.roleKey = roleKey;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "role")
	public Set<RolePrivilege> getRolePrivileges() {
		return this.rolePrivileges;
	}

	public void setRolePrivileges(Set<RolePrivilege> rolePrivileges) {
		this.rolePrivileges = rolePrivileges;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "role")
	public Set<CommunityRole> getCommunityRoles() {
		return this.communityRoles;
	}

	public void setCommunityRoles(Set<CommunityRole> communityRoles) {
		this.communityRoles = communityRoles;
	}

}
